package es.armaplus.struts.actions.clientes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import es.armaplus.business.ClienteBusiness;
import es.armaplus.business.BusinessFactory;
import es.armaplus.commons.Constantes;
import es.armaplus.struts.actions.BaseAction;

public class ListadoClientes extends BaseAction {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		/*
		 * Necesitamos obtener el listado de los clientes.
		 * Subirlo al request y mostrarlo.
		 */
		
		/*
		 * Tendremos un patr�n singelton para la capa de negocio.
		 * 
		 */

		
		String target = Constantes.FORWARD_SUCCESS;
		
		ClienteBusiness business = (ClienteBusiness) BusinessFactory.
				getBusiness(BusinessFactory.CLIENTE_BUSINESS);
		
		request.setAttribute(Constantes.ATTRIBUTE_CLIENTES, business.getClientes());
		
		return mapping.findForward(target);
	}


}
